Advertisement
saurabhmesh17

MAke Tut

Jun 24th, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.29 KB | None | 0 0
  1. #Sample file #
  2. root@saurabh:/home/saurabh/todo# tree Make_tutorial/
  3. Make_tutorial/
  4. |-- include
  5. |   `-- header.h
  6. |-- Makefile
  7. |-- obj
  8. `-- src
  9.     |-- add.c
  10.     |-- main.c
  11.     `-- sub.c
  12.  
  13. #ifndef __HEADER__
  14. #define __HEADER__
  15.  
  16. /* Standard Header files */
  17. #include <stdio.h>
  18.  
  19. /* Function Prototypes */
  20. int add(int x, int y);
  21. int sub(int x, int y);
  22.  
  23. #endif
  24. ~          
  25.  
  26. #include "header.h"
  27. int main (void)
  28. {
  29.     int a = 30, b = 20;
  30.     int res = add(a, b);
  31.     printf("Addition result: [%d]\n", res);
  32.    
  33.     int res = sub(a, b);
  34.     printf("Subtraction result: [%d]\n", res);
  35.    
  36.     return 0;
  37. }
  38.  
  39. /* Function for Addition of two Integers*/
  40. #include "header.h"
  41. int add(int x, int y)
  42. {
  43.     return x+y;
  44. }
  45.  
  46. /* Function for Subtraction of two Integers*/
  47. #include "header.h"
  48. int sub(int x, int y)
  49. {
  50.     return x-y;
  51. }
  52.  
  53. root@saurabh:/home/saurabh/todo/Make_tutorial# make
  54. [CC] src/main.c
  55. [CC] src/add.c
  56. [CC] src/sub.c
  57. [INFO] Creating Binary Executable exe
  58.  
  59.  
  60. root@saurabh:/home/saurabh/todo/Make_tutorial# make clean
  61. [Cleaning]
  62. removed `./obj/add.o'
  63. removed `./obj/main.o'
  64. removed `./obj/sub.o'
  65. removed `exe'
  66.  
  67.  
  68.  
  69. ../Make_tutorial/
  70. |-- exe
  71. |-- include
  72. |   `-- header.h
  73. |-- Makefile
  74. |-- obj
  75. |   |-- add.o
  76. |   |-- main.o
  77. |   `-- sub.o
  78. `-- src
  79.     |-- add.c
  80.     |-- main.c
  81.     `-- sub.c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement