1#*******************************************************************************
2# Copyright (c) 2000, 2010 IBM Corporation and others.
3#
4# This program and the accompanying materials
5# are made available under the terms of the Eclipse Public License 2.0
6# which accompanies this distribution, and is available at
7# https://www.eclipse.org/legal/epl-2.0/
8#
9# SPDX-License-Identifier: EPL-2.0
10#
11# Contributors:
12#     IBM Corporation - initial API and implementation
13#     Kevin Cornell (Rational Software Corporation)
14#     Silenio Quarti (IBM)
15#     Sam Robb (TimeSys Corporation)
16#*******************************************************************************
17include ../make_version.mak
18# Makefile for creating the eclipse launcher program.
19
20# This makefile expects the following environment variables set:
21#
22# PROGRAM_OUTPUT  - the filename of the output executable
23# PROGRAM_LIBRARY - the file of the output shared library
24# DEFAULT_OS      - the default value of the "-os" switch
25# DEFAULT_OS_ARCH - the default value of the "-arch" switch
26# DEFAULT_WS      - the default value of the "-ws" switch
27
28#if PROGRAM_OUTPUT is not set, assume eclipse.exe
29ifeq ($(PROGRAM_OUTPUT),)
30  PROGRAM_OUTPUT=eclipse.exe
31endif
32
33# Separate filename from extention
34PROGRAM_NAME=$(PROGRAM_OUTPUT:.exe=)
35
36PROGRAM_LIBRARY=eclipse_$(LIB_VERSION).dll
37
38# Allow for cross-compiling under linux
39OSTYPE	?= $(shell if uname -s | grep -iq cygwin ; then echo cygwin; else echo linux; fi)
40
41ifeq ($(OSTYPE),cygwin)
42CCVER   = i686
43CC      = i686-pc-cygwin-gcc-3
44RC      = windres
45else
46CCVER   = i586
47CC      = $(shell which i586-pc-cygwin-gcc)
48TDIR    = $(dir $(shell test -L $(CC) && readlink $(CC) || echo $(CC)))
49RC      = $(TDIR)/i586-pc-cygwin-windres
50SYSINC  = -isystem $(TDIR)/../include/mingw
51endif
52
53ifeq ($(CC),)
54$(error Unable to find $(CCVER)-pc-cygwin-gcc)
55endif
56
57# Define the object modules to be compiled and flags.
58MAIN_OBJS = eclipseMain.o
59COMMON_OBJS = eclipseConfig.o eclipseCommon.o   eclipseWinCommon.o
60DLL_OBJS	= eclipse.o  eclipseWin.o  eclipseUtil.o  eclipseJNI.o eclipseShm.o
61
62LIBS	= -lkernel32 -luser32 -lgdi32 -lcomctl32 -lmsvcrt -lversion
63LDFLAGS = -mwindows -mno-cygwin
64CONSOLEFLAGS = -mconsole -mno-cygwin
65DLL_LDFLAGS = -mno-cygwin -shared -Wl,--export-all-symbols -Wl,--kill-at,--image-base=0x72000000
66RES	= $(PROGRAM_NAME).res
67CONSOLE = $(PROGRAM_NAME)c.exe
68EXEC	= $(PROGRAM_OUTPUT)
69DLL     = $(PROGRAM_LIBRARY)
70DEBUG	= $(CDEBUG)
71CFLAGS	= -g -s -Wall \
72	  -I. -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 $(SYSINC) \
73	  -D_WIN32 \
74	  -DWIN32_LEAN_AND_MEAN \
75	  -mno-cygwin -D__int64="long long"
76WCFLAGS = -DUNICODE -I.. -DDEFAULT_OS="\"$(DEFAULT_OS)\"" \
77	  -DDEFAULT_OS_ARCH="\"$(DEFAULT_OS_ARCH)\"" \
78	  -DDEFAULT_WS="\"$(DEFAULT_WS)\"" \
79	  $(DEBUG) $(CFLAGS)
80
81all: $(EXEC) $(DLL) $(CONSOLE)
82
83eclipseMain.o: ../eclipseUnicode.h ../eclipseCommon.h ../eclipseMain.c
84	$(CC) $(DEBUG) $(WCFLAGS) -c -o $@ ../eclipseMain.c
85
86eclipseCommon.o: ../eclipseCommon.h ../eclipseUnicode.h ../eclipseCommon.c
87	$(CC) $(DEBUG) $(WCFLAGS) -c -o $@ ../eclipseCommon.c
88
89eclipseWinCommon.o: ../eclipseCommon.h eclipseWinCommon.c
90	$(CC) $(DEBUG) $(WCFLAGS) -c -o $@ eclipseWinCommon.c
91
92eclipse.o: ../eclipseOS.h ../eclipseUnicode.h ../eclipseJNI.h ../eclipseCommon.h ../eclipse.c
93	$(CC) $(DEBUG) $(WCFLAGS) -c -o $@ ../eclipse.c
94
95eclipseUtil.o: ../eclipseUtil.h ../eclipseUnicode.h ../eclipseUtil.c
96	$(CC) $(DEBUG) $(WCFLAGS) -c -o $@ ../eclipseUtil.c
97
98eclipseConfig.o: ../eclipseConfig.h ../eclipseUnicode.h ../eclipseConfig.c
99	$(CC) $(DEBUG) $(WCFLAGS) -c -o $@ ../eclipseConfig.c
100
101eclipseWin.o: ../eclipseOS.h ../eclipseUnicode.h eclipseWin.c
102	$(CC) $(DEBUG) $(WCFLAGS) -c -o $@ eclipseWin.c
103
104eclipseJNI.o: ../eclipseUnicode.h ../eclipseJNI.c
105	$(CC) $(DEBUG) $(WCFLAGS) -c -o $@ ../eclipseJNI.c
106
107eclipseShm.o: ../eclipseShm.h ../eclipseUnicode.h ../eclipseShm.c
108	$(CC) $(DEBUG) $(WCFLAGS) -c -o $@ ../eclipseShm.c
109
110$(RES): $(PROGRAM_NAME).rc
111	$(RC) --output-format=coff --include-dir=.. -o $@ $<
112
113$(EXEC): $(MAIN_OBJS) $(COMMON_OBJS) $(RES)
114	$(CC) $(LDFLAGS) -o $(EXEC) $(MAIN_OBJS) $(COMMON_OBJS) $(RES) $(LIBS)
115
116#the console version needs a flag set, should look for a better way to do this
117$(CONSOLE): $(MAIN_OBJS) $(COMMON_OBJS)
118	rm -f eclipseConfig.o aeclipseConfig.o
119	$(CC) $(DEBUG) $(WCFLAGS) -D_WIN32_CONSOLE -c -o eclipseConfig.o ../eclipseConfig.c
120	$(CC) $(CONSOLEFLAGS) -o $(CONSOLE) $(MAIN_OBJS) $(COMMON_OBJS) $(LIBS)
121
122$(DLL): $(DLL_OBJS) $(COMMON_OBJS)
123	$(CC) $(DLL_LDFLAGS) -o $(DLL) $(DLL_OBJS) $(COMMON_OBJS) $(LIBS)
124
125install: all
126	cp $(EXEC) $(DLL) $(CONSOLE) $(OUTPUT_DIR)
127	rm -f $(EXEC) $(DLL_OBJS) $(COMMON_OBJS) $(MAIN_OBJS) $(RES) $(CONSOLE)
128
129clean:
130	$(RM) $(EXEC) $(DLL) $(DLL_OBJS) $(COMMON_OBJS) $(MAIN_OBJS) $(RES) $(CONSOLE)
131