diff --git a/.gitignore b/.gitignore index 08922dccc5a85b6b1d5d767ebfecd7b368d6b5e7..d17f51572e34fd0b8d855b6c60076bf45f090349 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ *.o -main -main.exe +planetary_system +planetary_system.exe .vscode diff --git a/Makefile b/Makefile index eecedfe98605be8b4627f643a98ef99a6616db71..14a32177c173f34de2d8ba745b9dc87cc8c533e1 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,31 @@ -TARGET = main -# CCFLAGS +TARGET = planetary_system +LIBS = -lm CC = gcc -# CFLAGS:=-g -Ofast -Wall -Wextra -fsanitize=address -fsanitize=leak -std=gnu11 -# CFLAGS:=-fsanitize=address -CFLAGS = -g -O3 -Wall -Wextra -std=gnu11 -LDFLAGS = -lm +CFLAGS = -g -O3 -std=gnu11 ifeq ($(OS),Windows_NT) - LDFLAGS += -lopengl32 -lglu32 -lfreeglut + LIBS += -lopengl32 -lglu32 -lfreeglut else - LDFLAGS += -lGL -lGLU -lglut + LIBS += -lGL -lGLU -lglut endif +.PHONY: default all clean + +default: $(TARGET) +all: default + +OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c)) +HEADERS = $(wildcard *.h) + %.o: %.c $(HEADERS) $(CC) $(CFLAGS) -c $< -o $@ -$(TARGET): main.o Vector2.o CelestialObject.o PlanetarySystem.o drawing.o - $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) +.PRECIOUS: $(TARGET) $(OBJECTS) + +$(TARGET): $(OBJECTS) + $(CC) $(OBJECTS) -Wall -Wextra $(LIBS) -o $@ clean: - -rm -f *.o $(TARGET) $(TARGET).exe + -rm -f *.o + -rm -f $(TARGET) + diff --git a/main.c b/main.c index 50af256e25f1bb2a2c390024826ed8193e3458e4..87ba16c7a1249635a0b96ea3349101e59d824551 100644 --- a/main.c +++ b/main.c @@ -19,7 +19,7 @@ #include "drawing.h" // Name of the window. -const char WINDOW_NAME[] = "Solar System"; +const char WINDOW_NAME[] = "Planetary System"; // Refresh rate in Hz. const int32_t REFRESH_RATE = 200; // Number of microseconds in 1 second. @@ -108,7 +108,7 @@ void draw() { char title[100]; double elapsed_time = (double)(get_current_time() - start_time) / ONE_SECOND_IN_MICROSECONDS; - sprintf(title, "Solar System (%.2lf)", elapsed_time); + sprintf(title, "%s (%.2lf)", WINDOW_NAME, elapsed_time); glutSetWindowTitle(title); planetary_system_draw(planetary_system);