forked from packjpg/packPNM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (45 loc) · 1.28 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# packXXX Makefile, based on UniMake: Universal Makefile
# Created by Matthias Stirner, 01/2016
TARGET = pnmpack
CC = gcc
CPP = g++
RC = windres -O coff
CPPFLAGS = -I./src -O3 -Wall -pedantic -funroll-loops -ffast-math -fsched-spec-load -fomit-frame-pointer
LDFLAGS = -s #-static -static-libgcc -static-libstdc++
CSRC = $(wildcard src/*.c)
CPPSRC = $(wildcard src/*.cpp)
DEPS = $(wildcard src/*.h) Makefile
OBJ = $(patsubst %.c,%.o,$(CSRC)) $(patsubst %.cpp,%.o,$(CPPSRC))
# conditional stuff
ifeq ($(OS),Windows_NT)
LDFLAGS += -lpthread -L libwinpthread-1.dll
RES = src/icons.res
UPX := -upx --best --lzma $(TARGET).exe
else
CPPFLAGS += -DUNIX
RC =
RES =
UPX =
endif
%.o: %.cpp $(DEPS)
$(CPP) $(CPPFLAGS) -c -o $@ $<
%.res: %.rc
@-$(RC) $< $@
$(TARGET): $(OBJ) $(RES)
$(CPP) -o $@ $^ -s $(LDFLAGS)
$(UPX)
.PHONY: all dev lib dll
all: $(TARGET)
dev: CPPFLAGS += -DDEV_BUILD
dev: $(TARGET)
lib: CPPFLAGS += -DBUILD_LIB
lib: $(OBJ)
ar r $(TARGET)lib.a $(OBJ)
ranlib $(TARGET)lib.a
dll: CPPFLAGS += -DBUILD_DLL
dll: LDFLAGS += -Wl,--out-implib,libpackJPG.a -fvisibility=hidden
dll: $(OBJ)
$(CPP) -shared -o $(TARGET).dll $^ $(LDFLAGS)
clean:
@echo clean...
@-rm src/*.o src/*.a $(TARGET) $(TARGET).exe $(TARGET).dll