-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathMakefile
90 lines (65 loc) · 3.04 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
CFLAGS ?= -s -Os -I/opt/X11/include -Wall
LDFLAGS ?= -s -L/opt/X11/lib/
CC? = gcc
ICONSPATH = freedesktop/icons/hicolor/
APPNAME = com.github.cntools.cnping
all : cnping
#CFLAGS := $(CFLAGS) -DCNFGOGL
#LDFLAGS := $(LDFLAGS) -lGL
clean :
rm -rf *.o *~ cnping cnping.exe cnping_mac searchnet
rm -rf rawdraw/*.o
# Windows
#MINGW32 := /usr/bin/i686-w64-mingw32-
MINGW32 ?= i686-w64-mingw32-
# If you don't need admin privileges
ADMINFLAGS := $(ADMINFLAGS) -DWIN_USE_NO_ADMIN_PING
# Add git version to CFLAGS
GIT_VERSION := "$(shell git describe --abbrev=4 --dirty --always --tags)"
CFLAGS += -DVERSION=\"$(GIT_VERSION)\"
cnping-wingdi.exe : cnping.c ping.c httping.c resources.o
$(MINGW32)gcc -g -fno-ident -mwindows -m32 $(CFLAGS) -o $@ $^ -lgdi32 -lws2_32 -s -D_WIN32_WINNT=0x0600 -DWIN32 -liphlpapi -DMINGW_BUILD $(ADMINFLAGS)
cnping.exe : cnping.c ping.c httping.c resolve.c resources.o
$(MINGW32)gcc -g -fno-ident -mwindows -m32 -DCNFGOGL $(CFLAGS) -o $@ $^ -lgdi32 -lws2_32 -s -D_WIN32_WINNT=0x0600 -DWIN32 -liphlpapi -lopengl32 -DMINGW_BUILD $(ADMINFLAGS)
resources.o : resources.rc
$(MINGW32)windres resources.rc -o resources.o $(ADMINFLAGS)
# Unix
cnping : cnping.c ping.c httping.c resolve.c
$(CC) $(CFLAGS) -o $@ $^ -lX11 -lm -lpthread -lGL $(LDFLAGS)
cnping_ogl : cnping.c ping.c httping.c resolve.c
$(CC) $(CFLAGS) -o $@ $^ -DCNFGOGL $(CFLAGS) -lX11 -lm -lpthread $(LDFLAGS) -lGL
cnping_mac : cnping.c ping.c httping.c resolve.c
$(CC) -o cnping $^ -x objective-c -framework Cocoa -framework QuartzCore -lm -lpthread -DOSX
searchnet : ping.c searchnet.c resolve.c
$(CC) $(CFLAGS) -o $@ $^ -lpthread
linuxinstall : cnping
rm -f /usr/local/bin/cnping
cp cnping /usr/local/bin/
cp -r $(ICONSPATH) /usr/local/share/icons
cp freedesktop/${APPNAME}.desktop /usr/local/share/applications
cp freedesktop/${APPNAME}.metainfo.xml /usr/local/share/metainfo
setcap cap_net_raw+ep /usr/local/bin/cnping
# sudo chmod +t /usr/local/bin/cnping #One option - set the stuid bit.
# sudo install cnping /usr/local/bin/ #Another option - using install.
# minimal linux install, may be useful for development
minlinuxinstall : cnping
sudo rm -f /usr/local/bin/cnping
sudo cp cnping /usr/local/bin/
sudo setcap cap_net_raw+ep /usr/local/bin/cnping
# this target requires imagemagick
updateicons : ${ICONSPATH}scalable/apps/${APPNAME}.svg
convert $^ -resize 16x16 ${ICONSPATH}16x16/apps/${APPNAME}.png
convert $^ -resize 32x32 ${ICONSPATH}32x32/apps/${APPNAME}.png
convert $^ -resize 48x48 ${ICONSPATH}48x48/apps/${APPNAME}.png
convert $^ -resize 256x256 ${ICONSPATH}256x256/apps/${APPNAME}.png
convert $^ -resize 1024x1024 ${ICONSPATH}1024x1024/apps/${APPNAME}.png
# after creating the ico file use GIMP to compress it:
# Image-> Mode -> Indexed...
# Choose "Generate optimum palette"
# Maximum number of colors: 3 (may change if the icon changes)
# "Convert"
# File -> Export As
# Check "Compressed (PNG)" in every resolution
# "Export"
cnping.ico: ${ICONSPATH}scalable/apps/${APPNAME}.svg
convert $^ -density 300 -define icon:auto-resize=256,64,16 -background none $@