Makefile GTK+ pour linux

cooleric Messages postés 10 Date d'inscription mardi 6 mai 2003 Statut Membre Dernière intervention 16 mars 2004 - 2 sept. 2003 à 23:00
cooleric Messages postés 10 Date d'inscription mardi 6 mai 2003 Statut Membre Dernière intervention 16 mars 2004 - 3 sept. 2003 à 14:59
QQn pourait menvoyer un exemple de makefile pour un projet gtk sous linux?

Merci

3 réponses

cs_Nebula Messages postés 787 Date d'inscription samedi 8 juin 2002 Statut Membre Dernière intervention 7 juin 2007 2
3 sept. 2003 à 12:35
sous linux seulement :
.PHONY: all clean

SRC = fichier_1.c fichier_2.c fichier_3.c
OBJ = $(SRC:.c=.o)
BIN = le_nom_de_ton_programme

CFLAGS = `pkg-config --cflags gtk+-2.0`
LFLAGS = `pkg-config --libs gtk+-2.0`

CC = gcc -c $< $(CFLAGS) -o $@
LD = gcc -s $^ $(LFLAGS) -o $@
RM = rm -f $(OBJ) $(BIN)

all: $(BIN)

%.o: %.c *.h
$(CC)

%.o: %.c
$(CC)

$(BIN): $(OBJ)
$(LD)

clean:
$(RM)


sous windows seulement :
.PHONY: all clean

SRC = fichier_1.c fichier_2.c fichier_3.c
OBJ = $(SRC:.c=.o)
BIN = le_nom_de_ton_programme.exe

CFLAGS = -mconsole -mno-cygwin -mms-bitfields
LFLAGS = -latk-1.0.dll -lbluecurve.dll -lfreetype.dll -lgdk_pixbuf-2.0.dll -lgdk-win32-2.0.dll -lglib-2.0.dll -lgmodule-2.0.dll -lgobject-2.0.dll -lgthread-2.0.dll -lgtk-win32-2.0.dll -lintl.dll -ljpeg.dll -llighthouseblue.dll -lpango-1.0.dll -lpangoft2-1.0.dll -lpangowin32-1.0.dll -lpng.dll -lpng12.dll -ltiff.dll -lz.dll -lgdi32 -lole32 -luuid

CC = gcc -c $< $(CFLAGS) -o $@
LD = gcc -s $^ $(LFLAGS) -o $@
RM = del /F /Q $(OBJ) $(BIN)

all: $(BIN)

%.o: %.c *.h
$(CC)

%.o: %.c
$(CC)

$(BIN): $(OBJ)
$(LD)

clean:
$(RM)


makefile générique windows et linux :
.PHONY: all clean

SRC = fichier_1.c fichier_2.c fichier_3.c
OBJ = $(SRC:.c=.o)

ifeq ($(SHELL),sh.exe)
CFLAGS = -mconsole -mno-cygwin -mms-bitfields
LFLAGS = -latk-1.0.dll -lbluecurve.dll -lfreetype.dll -lgdk_pixbuf-2.0.dll -lgdk-win32-2.0.dll -lglib-2.0.dll -lgmodule-2.0.dll -lgobject-2.0.dll -lgthread-2.0.dll -lgtk-win32-2.0.dll -lintl.dll -ljpeg.dll -llighthouseblue.dll -lpango-1.0.dll -lpangoft2-1.0.dll -lpangowin32-1.0.dll -lpng.dll -lpng12.dll -ltiff.dll -lz.dll -lgdi32 -lole32 -luuid
BIN = le_nom_de_ton_programme.exe
RM = del /F /Q
else
CFLAGS = `pkg-config --cflags gtk+-2.0`
LFLAGS = `pkg-config --libs gtk+-2.0`
BIN = le_nom_de_ton_programme
RM = rm -f
endif

CC = gcc -c $< $(CFLAGS) -o $@
LD = gcc -s $^ $(LFLAGS) -o $@
RM += $(OBJ) $(BIN)

all: $(BIN)

%.o: %.c *.h
$(CC)

%.o: %.c
$(CC)

$(BIN): $(OBJ)
$(LD)

clean:
$(RM)


Si tu utilises C++ plutôt que C, remplace 'gcc' par 'g++', et çà devrait fonctionner...

A+
0
cs_Nebula Messages postés 787 Date d'inscription samedi 8 juin 2002 Statut Membre Dernière intervention 7 juin 2007 2
3 sept. 2003 à 12:38
Arf, çà a pas pris les tabulations...

Va voir cet exemple : http://caranarchie.free.fr/sample.zip

A+
0
cooleric Messages postés 10 Date d'inscription mardi 6 mai 2003 Statut Membre Dernière intervention 16 mars 2004
3 sept. 2003 à 14:59
Merci c'est nickel!
0
Rejoignez-nous