File: Makefile

package info (click to toggle)
uswsusp 0.7-1.2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,000 kB
  • ctags: 962
  • sloc: ansic: 6,060; xml: 755; sh: 425; makefile: 176
file content (157 lines) | stat: -rw-r--r-- 4,286 bytes parent folder | download
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#CONFIG_COMPRESS=yes
#CONFIG_ENCRYPT=yes
#CONFIG_SPLASHY=yes
#CONFIG_UDEV=yes
#CONFIG_RESUME_DYN=yes

PREFIX=/usr/local
SUSPEND_DIR=$(PREFIX)/sbin
RESUME_DIR=$(PREFIX)/lib/suspend
CONFIG_DIR=/etc
RESUME_DEVICE=<path_to_resume_device_file>
BOOT_DIR=/boot
CONFIGFILE=suspend.conf
CFLAGS := -O2 -Wall

###############################################################

ARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ -e s/ppc.*/ppc/)

CC_FLAGS=-I/usr/local/include -DS2RAM $(CFLAGS)
LD_FLAGS=-L/usr/local/lib

BINARIES=s2disk s2both s2ram swap-offset resume
BINARIES_MIN=s2disk swap-offset

S2RAM_OBJ=vt.o config_parser.o
SWSUSP_OBJ=vt.o md5.o encrypt.o config_parser.o loglevel.o splash.o bootsplash.o

S2RAM_LD_FLAGS = $(LD_FLAGS)
SWSUSP_LD_FLAGS = $(LD_FLAGS)
ifeq ($(ARCH), x86)
S2RAM_OBJ += s2ram-x86.o whitelist.o dmidecode.o radeontool.o vbetool/vbetool.o
S2RAM_LD_FLAGS += -lx86 -lpci
endif
ifeq ($(ARCH), ppc)
S2RAM_OBJ += s2ram-ppc.o
endif

ifndef CONFIG_RESUME_DYN
STATIC_LD_FLAGS = -static
endif

ifdef CONFIG_COMPRESS
CC_FLAGS	+= -DCONFIG_COMPRESS
SWSUSP_LD_FLAGS	+= -llzo2
endif

ifdef CONFIG_ENCRYPT
BINARIES	+= suspend-keygen 
BINARIES_MIN	+= suspend-keygen 
CC_FLAGS	+= -DCONFIG_ENCRYPT
GCRYPT_CC_FLAGS	= $(shell libgcrypt-config --cflags)
SWSUSP_CC_FLAGS	+= $(GCRYPT_CC_FLAGS)
GCRYPT_LD_FLAGS = $(shell libgcrypt-config --libs)
SWSUSP_LD_FLAGS += $(GCRYPT_LD_FLAGS)
INSTALL_KEYGEN	= install-keygen
endif

ifndef CONFIG_UDEV
SNAPSHOT=$(DESTDIR)/dev/snapshot
endif

ifdef CONFIG_SPLASHY
SWSUSP_OBJ	+= splashy_funcs.o 
CC_FLAGS	+= -DCONFIG_SPLASHY
SWSUSP_LD_FLAGS	+= -lsplashy
ifndef CONFIG_RESUME_DYN
STATIC_LD_FLAGS += -lsplashycnf \
		$(shell directfb-config  --libs --input=keyboard \
		--imageprovider=jpeg,gif,png\
		--font=ft2,default) \
		$(shell pkg-config --static --libs glib-2.0)
STATIC_CC_FLAGS=$(shell directfb-config --cflags)\
		$(shell pkg-config --static --cflags glib-2.0)
else
SWSUSP_LD_FLAGS += -lgcc_s
endif
endif



all: $(BINARIES) 

clean: 
	rm -f $(BINARIES) suspend-keygen suspend.keys *.o vbetool/*.o

#### Rules for objects
s2ram-x86.o: %.o : %.c %.h
	$(CC) $(CC_FLAGS) -c $< -o $@

s2ram-both.o: s2ram.c s2ram.h
	$(CC) $(CC_FLAGS) -DCONFIG_BOTH -c $< -o $@

md5.o encrypt.o: %.o : %.c %.h md5.h
	$(CC) $(CC_FLAGS) -DHAVE_INTTYPES_H -DHAVE_STDINT_H -c $< -o $@

# Simple objects with header
config_parser.o vt.o bootsplash.o splash.o splashy_funcs.o vbetool/vbetool.o s2ram-ppc.o: %.o : %.c %.h
	$(CC) $(CC_FLAGS) -c $< -o $@

# Simple object without header
dmidecode.o radeontool.o : %.o: %.c
	$(CC) $(CC_FLAGS) -c $< -o $@

#### Rules for binaries
s2disk:	$(SWSUSP_OBJ) suspend.c
	$(CC) -g $(CC_FLAGS)  $^ -o $@ $(SWSUSP_LD_FLAGS)

s2ram:	$(S2RAM_OBJ) s2ram.c s2ram-main.c
	$(CC) -g $(CC_FLAGS) -include s2ram-$(ARCH).h $^ -o $@ $(S2RAM_LD_FLAGS)

s2both:	$(SWSUSP_OBJ) $(S2RAM_OBJ) s2ram-both.o suspend.c 
	$(CC) -g $(CC_FLAGS) -include s2ram-$(ARCH).h -DCONFIG_BOTH  $^ -o $@ $(SWSUSP_LD_FLAGS) $(S2RAM_LD_FLAGS)

resume:	resume.c $(SWSUSP_OBJ)
	$(CC) $(CC_FLAGS) $(STATIC_CC_FLAGS) $^ -o $@ $(SWSUSP_LD_FLAGS) $(STATIC_LD_FLAGS) 
swap-offset: swap-offset.c
	$(CC) $(CC_FLAGS) $< -o $@ $(LD_FLAGS)

suspend-keygen:	 keygen.c md5.o encrypt.h 
	$(CC) $(CC_FLAGS) $(GCRYPT_CC_FLAGS) -DHAVE_INTTYPES_H -DHAVE_STDINT_H md5.o $< -o $@ $(LD_FLAGS) $(GCRYPT_LD_FLAGS)




#### Install targets
$(SNAPSHOT):
	mknod $(SNAPSHOT) c 10 231;

install-conf: conf/$(CONFIGFILE)
	if [ -f $(DESTDIR)$(CONFIG_DIR)/$(CONFIGFILE) ]; then \
		install --mode=644 conf/$(CONFIGFILE) \
			$(DESTDIR)$(CONFIG_DIR)/$(CONFIGFILE).new;\
	else \
		install -D --mode=644 conf/$(CONFIGFILE) \
			$(DESTDIR)$(CONFIG_DIR)/$(CONFIGFILE); \
	fi

install-resume:
	install -D --mode=755 resume $(DESTDIR)$(RESUME_DIR)/resume

install-% : %
	install -D --mode=755 $< $(DESTDIR)$(SUSPEND_DIR)/$<

# Some convenience targets
install-resume-new-initrd:	resume conf/$(CONFIGFILE)
	BOOT_DIR=$(DESTDIR)$(BOOT_DIR) ./scripts/create-resume-initrd.sh $(RESUME_DEVICE)

install-resume-on-initrd:	resume 
	./scripts/install-resume.sh

install-minimal: $(patsubst %,install-%,$(BINARIES_MIN)) $(SNAPSHOT) install-conf

install: $(patsubst %,install-%,$(BINARIES)) $(SNAPSHOT) install-conf


.PHONY: clean install install-minimal install-resume-on-initrd install-resume-new-initrd