1 # ---------------------------------------------------------------------------
3 # ---------------------------------------------------------------------------
15 $(info Options
: DEBUG
=$(DEBUG
), NALYZE
=$(NALYZE
), ASAN
=$(ASAN
), STATIC
=$(STATIC
), FLTO
=$(FLTO
), FPGO
=$(FPGO
), STRIP
=$(STRIP
), CPU
=$(CPU
), THREAD
=$(THREAD
))
17 # ---------------------------------------------------------------------------
19 # ---------------------------------------------------------------------------
21 SUBDIR_APP
:= frontend
22 SUBDIR_LIB
:= libslunkcrypt
24 # ---------------------------------------------------------------------------
26 # ---------------------------------------------------------------------------
28 CFLAGS
= -I
$(SUBDIR_LIB
)/include -std
=gnu99
-Wall
-pedantic
30 ifneq (,$(firstword $(filter 32 64,$(CPU
))))
31 CFLAGS
+= -m
$(firstword $(CPU
))
33 ifneq (,$(firstword $(TARGET
)))
34 CFLAGS
+= --target
=$(firstword $(TARGET
))
35 LDFLGS
+= --target
=$(firstword $(TARGET
))
38 ifneq (,$(firstword $(MARCH
)))
39 CFLAGS
+= -march
=$(firstword $(MARCH
))
41 ifneq (,$(firstword $(MTUNE
)))
42 CFLAGS
+= -mtune
=$(firstword $(MTUNE
))
47 CFLAGS
+= -O1
-g
-fsanitize
=address
-fno-omit-frame-pointer
-fno-optimize-sibling-calls
53 CFLAGS
+= -O3
-DNDEBUG
58 CFLAGS
+= -fprofile-
$(firstword $(FPGO
))
66 MACHINE
:= $(strip $(shell $(CC
) -dumpmachine
))
68 $(error Failed to determine target machine
, please
check CC is working
!)
70 $(info Target machine type
: $(MACHINE
))
73 ifneq (,$(firstword $(filter %mingw32
%-windows-gnu
%-cygwin
%-cygnus
,$(MACHINE
))))
77 ifneq (,$(firstword $(filter %-w64-mingw32
%w64-windows-gnu
,$(MACHINE
))))
78 LDFLGS
+= -mconsole
-municode
92 CFLAGS
+= -DSLUNKBUILD_NOTHREADS
95 ifneq (,$(firstword $(filter %-pc-haiku
%-unknown-haiku
,$(MACHINE
))))
99 # ---------------------------------------------------------------------------
101 # ---------------------------------------------------------------------------
103 OUTNAME_APP
:= slunkcrypt
$(CONFIG
)$(EXE_SUFFIX
)
104 OUTNAME_LIB
:= libslunkcrypt
$(CONFIG
)-1.a
106 OUTPATH_APP
:= $(SUBDIR_APP
)/bin
/$(OUTNAME_APP
)
107 OUTPATH_LIB
:= $(SUBDIR_LIB
)/lib
/$(OUTNAME_LIB
)
109 SOURCES_APP
:= $(wildcard $(SUBDIR_APP
)/src
/*.c
)
110 OBJECTS_APP
:= $(patsubst $(SUBDIR_APP
)/src
/%.c
,$(SUBDIR_APP
)/obj
/%$(CONFIG
).o
,$(SOURCES_APP
))
112 SOURCES_LIB
:= $(wildcard $(SUBDIR_LIB
)/src
/*.c
)
113 OBJECTS_LIB
:= $(patsubst $(SUBDIR_LIB
)/src
/%.c
,$(SUBDIR_LIB
)/obj
/%$(CONFIG
).o
,$(SOURCES_LIB
))
115 ifneq ($(filter %-mingw32
%-windows-gnu
%-cygwin
%-cygnus
,$(MACHINE
)),)
116 RCFILES_APP
:= $(wildcard $(SUBDIR_APP
)/res
/*.rc
)
117 OBJECTS_APP
+= $(patsubst $(SUBDIR_APP
)/res
/%.rc
,$(SUBDIR_APP
)/obj
/%.rsrc.o
,$(RCFILES_APP
))
120 # ---------------------------------------------------------------------------
122 # ---------------------------------------------------------------------------
128 $(OUTPATH_APP
): $(OBJECTS_APP
) $(OUTPATH_LIB
)
130 $(CC
) $(CFLAGS
) $^
-o
$@
$(LDFLGS
)
132 $(OUTPATH_LIB
): $(OBJECTS_LIB
)
136 $(SUBDIR_APP
)/obj
/%$(CONFIG
).o
: $(SUBDIR_APP
)/src
/%.c
138 $(CC
) $(CFLAGS
) -c
$< -o
$@
140 $(SUBDIR_APP
)/obj
/%.rsrc.o
: $(SUBDIR_APP
)/res
/%.rc
144 $(SUBDIR_LIB
)/obj
/%$(CONFIG
).o
: $(SUBDIR_LIB
)/src
/%.c
146 $(CC
) $(CFLAGS
) -c
$< -o
$@
149 $(RM
) $(SUBDIR_APP
)/obj
/*.o
$(SUBDIR_APP
)/obj
/*.gcda
$(SUBDIR_APP
)/lib
/*.a
$(SUBDIR_APP
)/bin
/*$(EXE_SUFFIX
)
150 $(RM
) $(SUBDIR_LIB
)/obj
/*.o
$(SUBDIR_LIB
)/obj
/*.gcda
$(SUBDIR_LIB
)/lib
/*.a
$(SUBDIR_LIB
)/bin
/*$(EXE_SUFFIX
)