Skip to content

Commit

Permalink
'makefile' : .c files were sometimes compiled as C++, which is now de…
Browse files Browse the repository at this point in the history
…precated behavior. We now use gcc for all .c files and g++ for all .cpp files.
  • Loading branch information
Bill-Gray committed Sep 26, 2023
1 parent 0319126 commit f725be4
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# As CC is an implicit variable, a simple CC?=g++ doesn't work.
# We have to use this trick from https://stackoverflow.com/a/42958970
ifeq ($(origin CC),default)
CC=g++
CC=gcc
CPP=g++
endif
EXE=
RM=rm -f
Expand All @@ -39,13 +40,15 @@ endif
LIB_DIR=$(INSTALL_DIR)/lib

ifdef W64
CC=x86_64-w64-mingw32-g++
CC=x86_64-w64-mingw32-gcc
CPP=x86_64-w64-mingw32-g++
EXE=.exe
LIB_DIR=$(INSTALL_DIR)/win_lib
endif

ifdef W32
CC=i686-w64-mingw32-g++
CC=i686-w64-mingw32-gcc
CPP=i686-w64-mingw32-g++
EXE=.exe
LIB_DIR=$(INSTALL_DIR)/win_lib32
endif
Expand All @@ -69,14 +72,14 @@ all: dropouts$(EXE) fake_ast$(EXE) fix_tles$(EXE) get_high$(EXE) \
out_comp$(EXE) sat_cgi$(EXE) sat_eph$(EXE) sat_id$(EXE) sat_id2$(EXE) summarize$(EXE) \
test_des$(EXE) test_out$(EXE) test_sat$(EXE) test2$(EXE) tle2mpc$(EXE)

CFLAGS+=-Wextra -Wall -O3 -pedantic
CFLAGS+=-Wextra -Wall -O3 -pedantic -Werror

ifdef DEBUG
CFLAGS += -g
ifdef UCHAR
CFLAGS += -funsigned-char
endif

ifdef ERRORS
CFLAGS += -Werror
ifdef DEBUG
CFLAGS += -g
endif

clean:
Expand Down Expand Up @@ -150,10 +153,10 @@ fix_tles$(EXE): fix_tles.o libsatell.a
$(CC) $(CFLAGS) -o fix_tles$(EXE) fix_tles.o libsatell.a -lm

get_vect$(EXE): get_vect.cpp observe.o libsatell.a
$(CC) $(CFLAGS) -o get_vect$(EXE) -I $(INCL) get_vect.cpp observe.o libsatell.a -lm -L $(LIB_DIR) -llunar
$(CPP) $(CFLAGS) -o get_vect$(EXE) -I $(INCL) get_vect.cpp observe.o libsatell.a -lm -L $(LIB_DIR) -llunar

line2$(EXE): line2.cpp libsatell.a
$(CC) $(CFLAGS) -o line2$(EXE) -I $(INCL) line2.cpp libsatell.a -lm -L $(LIB_DIR) -llunar
$(CPP) $(CFLAGS) -o line2$(EXE) -I $(INCL) line2.cpp libsatell.a -lm -L $(LIB_DIR) -llunar

out_comp$(EXE): out_comp.o
$(CC) $(CFLAGS) -o out_comp$(EXE) out_comp.o -lm
Expand All @@ -168,11 +171,11 @@ sat_eph$(EXE): sat_eph.c observe.o libsatell.a
sat_cgi$(EXE): sat_eph.c observe.o libsatell.a
$(CC) $(CFLAGS) -o sat_cgi$(EXE) -I $(INCL) sat_eph.c observe.o -DON_LINE_VERSION libsatell.a -lm -L $(LIB_DIR) -llunar

sat_id$(EXE): sat_id.cpp sat_util.c observe.o libsatell.a
$(CC) $(CFLAGS) -o sat_id$(EXE) -I $(INCL) sat_id.cpp sat_util.c observe.o libsatell.a -lm -L $(LIB_DIR) -llunar
sat_id$(EXE): sat_id.cpp sat_util.o observe.o libsatell.a
$(CPP) $(CFLAGS) -o sat_id$(EXE) -I $(INCL) sat_id.cpp sat_util.o observe.o libsatell.a -lm -L $(LIB_DIR) -llunar

sat_id2$(EXE): sat_id2.cpp sat_id.cpp sat_util.c observe.o libsatell.a
$(CC) $(CFLAGS) -o sat_id2$(EXE) -I $(INCL) -DON_LINE_VERSION sat_id2.cpp sat_id.cpp sat_util.c observe.o libsatell.a -lm -L $(LIB_DIR) -llunar
sat_id2$(EXE): sat_id2.cpp sat_id.cpp sat_util.o observe.o libsatell.a
$(CPP) $(CFLAGS) -o sat_id2$(EXE) -I $(INCL) -DON_LINE_VERSION sat_id2.cpp sat_id.cpp sat_util.o observe.o libsatell.a -lm -L $(LIB_DIR) -llunar

summarize$(EXE): summarize.c observe.o libsatell.a
$(CC) $(CFLAGS) -o summarize$(EXE) -I $(INCL) summarize.c observe.o libsatell.a -lm -L $(LIB_DIR) -llunar
Expand All @@ -190,7 +193,7 @@ tle_date.cgi: tle_date.c
$(CC) $(CFLAGS) -o tle_date.cgi -I../include -DON_LINE_VERSION tle_date.c -L $(LIB_DIR) -llunar

tle2mpc$(EXE): tle2mpc.cpp libsatell.a
$(CC) $(CFLAGS) -o tle2mpc$(EXE) -I $(INCL) tle2mpc.cpp libsatell.a -lm -L $(LIB_DIR) -llunar
$(CPP) $(CFLAGS) -o tle2mpc$(EXE) -I $(INCL) tle2mpc.cpp libsatell.a -lm -L $(LIB_DIR) -llunar

test_des$(EXE): test_des.o libsatell.a
$(CC) $(CFLAGS) -o test_des$(EXE) test_des.o libsatell.a -lm
Expand All @@ -202,4 +205,7 @@ test_sat$(EXE): test_sat.o libsatell.a
$(CC) $(CFLAGS) -o test_sat$(EXE) test_sat.o libsatell.a -lm

.cpp.o:
$(CPP) $(CFLAGS) -c $<

.c.o:
$(CC) $(CFLAGS) -c $<

0 comments on commit f725be4

Please sign in to comment.