[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Unix Makefile

Does anyone have a Unix Makefile that will compile both JAVA and C/C++.

Thanks in advance!
0
jefftk
Asked:
jefftk
1 Solution
 
shchukaCommented:
This is relatively simple.  Assuming that your path and classpath are set correctly...

#Makefile starts here
JAVAC = javac
CC = gxx
JAVAFLAGS = whatever parameters you need
CFLAGS = whatever parameters you need
LDFLAGS = whatever you need
CPROGRAMNAME = name of your cpp output file

all: javafiles cppfiles
    #do whatever you need with them together after each part is compiled

javafiles: class1 class2

cppfiles: cprograms

class1: class1.java
    $(JAVAC) $(JAVAFLAGS) class1.java

class2: class2.java
    $(JAVAC) $(JAVAFLAGS) class2.java

cppfiles: file1.o file2.o
    $(CC) $(LDFLAGS) -o $(CPROGRAMNAME) file1.o file2.o

file1.o file1.c file1.h
    $(CC) -c $(CFLAGS) file1.c

file2.o file2.c file2.h
    $(CC) -c $(CFLAGS) file2.c

#End of make file
0
 
jefftkAuthor Commented:
Thank you.
I will try to implement this code.


0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now